# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=smartmontools
pkgver=7.4
pkgrel=1
pkgdesc="Control and monitor S.M.A.R.T. enabled hard drives"
url="https://www.smartmontools.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-openrc"
source="https://downloads.sourceforge.net/sourceforge/smartmontools/smartmontools-$pkgver.tar.gz
	fix-segfault-in-option-handling.patch
	smartd.initd
	smartd.confd
	"
prepare() {
 	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir"/ install

	install -Dm755 "$srcdir"/smartd.initd "$pkgdir"/etc/init.d/smartd
	install -Dm644 "$srcdir"/smartd.confd "$pkgdir"/etc/conf.d/smartd
}

sha512sums="
439fbf8d0e77fbe1d5a9fb100e655a7e47a82382ce8e1a4e942541a4dfbdff3391caa635e8d354d0e87c10ae79cb97aa6d24915f9f193620d763b384baf2e753  smartmontools-7.4.tar.gz
d41ba269b46591e605a87e043acd77fd2de3a723405fc83de0848afa8592f1ad912c5ac1e8199b10008ea53d8cfbc4917bf037578e7242346945664caa5bfc48  fix-segfault-in-option-handling.patch
4a2cbdab37cf0d761924854be4a2f2deebed22ca8d8754dee9a5ec44229c608f5fffb19545d2b9c687ab010460acde51d4f5fccd74d6c80dab2b1a7401d59b9f  smartd.initd
9088b97fbaac45e677e5ac14bc8a9edb4bd7a924717bb201db92f4a85447bb0e0254e716c8c8e60d4830b96e3221488fc80b30442b2e4a1b57741535aa2c3e7b  smartd.confd
"
